package com.tust.androidreader;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper  extends SQLiteOpenHelper {
    private static final String DBNAME = "reader.db";
    private static final int VERSION = 1;

    public DBHelper(@Nullable Context context) {
        super(context, DBNAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(
            "create table if not exists user(" +
                "username varchar(30) not null primary key," +
                "password varchar(30) not null)");

        sqLiteDatabase.execSQL("insert into user values (?, ?)", new Object[]{"admin", "admin"});
        //sqLiteDatabase.execSQL("insert into user values (?, ?)", new Object[]{1, 1});//便于调试
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
